package dyyx.cli;

import java.util.List;

import dyyx.util.CommUtil;
import dyyx.util.FileUtil;

/**
 * 文件读取测试 /proc/sys/fs/file-nr  CommUtil.read 只能读取到第一个字节
 * @author dugang
 *
 */
public class FileReadMain {
	
	private final static String SEP = "-----------------";
    public static void main(String[] args) throws Exception{   	  	  
        int argnum = args.length;
        System.out.println("argnum="+argnum);
        if(argnum<=0){
        	System.out.println("file is blank");
        	return;
        }
        
        String file = args[0]; 
        System.out.println("file="+file);
        
        
        System.out.println("readStringOneByteOnce");

        String str = FileUtil.readStringOneByteOnce(file,null);

        System.out.println(SEP);
        System.out.println("CommUtil.read");
        System.out.println(SEP);

        System.out.println(str);

        System.out.println(SEP);
       
        System.out.println("readStringUseBufferByteArray");
        System.out.println(SEP);

        str = FileUtil.readString(file,null);
        System.out.println(str);

        System.out.println(SEP);
        
        System.out.println("CommUtil.readLines");
        List<String> lines = CommUtil.readLines(file, null, false);

        
        System.out.println(SEP);

        if(lines==null){
            System.out.println("null");
        	return;
        }
        for(String line:lines){
        	System.out.println(line);
        }
        
        System.out.println(SEP);

        
    }
    
   
}
